<?php

namespace catchAdmin\pc\tables;

use catchAdmin\pc\tables\forms\Factory;
use catcher\CatchTable;
use catcher\library\table\Actions;
use catcher\library\table\HeaderItem;
use catcher\library\table\Search;

class Banner extends CatchTable
{

    public function Table()
    {
        return $this->getTable('banner')
            ->header([
                HeaderItem::label('名称')->prop('title'),
                HeaderItem::label('位置')->prop('type_name'),
                HeaderItem::label('显示开始日期')->prop('from_date'),
                HeaderItem::label('显示结束日期')->prop('to_date'),
                HeaderItem::label('图片')->prop('img')->withPreviewComponent(),
                HeaderItem::label('操作')
                    ->actions([
                        Actions::update(),
                        Actions::delete(),
                    ])
                    ->width(260),
            ])
            ->withSearch([
                Search::label('名称')->text('title', '名称')->clearable(true),
                Search::label('位置')
                    ->select('type', '位置', tableSelectArray((new \catchAdmin\model\Banner())->getTypeList()))
                    ->style(['width' => '100px'])
                    ->clearable(true),
//                Search::label('图片')->text('img', '名称')->(true),

            ])
            ->selectionChange()
            ->withApiRoute('banner')
            ->withActions([
                Actions::create(),
            ])
            ->render();
    }


    public function form()
    {
        return Factory::create('banner');
    }

}
